package com.youdelu.road.utils;

import android.app.Activity;
import android.content.Context;
import android.util.Log;

import com.google.gson.Gson;
import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.db.sqlite.Selector;
import com.lidroid.xutils.db.sqlite.WhereBuilder;
import com.qozix.tileview.TileView;
import com.qozix.tileview.plugins.MarkerPlugin;
import com.stickerview.view.JTDView;
import com.stickerview.view.StickerImageView;
import com.youdelu.road.R;
import com.youdelu.road.bean.Attr;
import com.youdelu.road.bean.FileDir;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


public class Util {

    public static  DbUtils db ;
    public static final String DB_NAME = "file_dirs";
    public static DbUtils init(Context mContext){
        db= DbUtils.create(mContext,DB_NAME);
        createTable(db);
        return db;
    }
    private static String[][] data = {

            {"k433+140-1","13126","9850","1","0","1","1"},
            {"k433+140-2","13126","9880","1","0","1","1"},
            {"k433+140-3","13126","9910","1","0","1","1"},
            {"k433+140-4","13176","9850","1","1","1","1"},
            {"k433+140-5","13176","9880","1","1","1","1"},
            {"k433+140-6","13176","9910","1","1","1","1"},

            {"k433+140-情报板","13150","9850","1","1","3","1"},

            {"k433+310-1","13255","9720","0","1","1","1"},
            {"k433+310-2","13255","9750","0","1","1","1"},
            {"k433+310-3","13255","9780","0","1","1","1"},
            {"k433+310-4","13305","9720","0","0","1","1"},
            {"k433+310-5","13305","9750","0","0","1","1"},
            {"k433+310-6","13305","9780","0","0","1","1"},

            {"k433+310-情报板","13280","9720","0","1","3","1"},

            {"k435+113-1","13785","9850","1","0","1","1"},
            {"k435+113-2","13785","9880","1","0","1","1"},
            {"k435+113-3","13785","9910","1","0","1","1"},
            {"k435+113-4","13835","9850","1","1","1","1"},
            {"k435+113-5","13835","9880","1","1","1","1"},
            {"k435+113-6","13835","9910","1","1","1","1"},

            {"k435+113-情报板","13810","9850","1","0","3","1"},

            {"k435+420-1","13853","9720","0","1","0","1"},
            {"k435+420-2","13853","9750","0","1","0","1"},
            {"k435+420-3","13853","9780","0","1","0","1"},
            {"k435+420-4","13903","9720","0","0","0","1"},
            {"k435+420-5","13903","9750","0","0","0","1"},
            {"k435+420-6","13903","9780","0","0","0","1"},

            {"k435+475-1","14037","9850","1","0","0","1"},
            {"k435+475-2","14037","9880","1","0","0","1"},
            {"k435+475-3","14037","9910","1","0","0","1"},
            {"k435+475-4","14088","9850","1","1","0","1"},
            {"k435+475-5","14088","9880","1","1","0","1"},
            {"k435+475-6","14088","9910","1","1","0","1"},

            {"k435+780-1","14098","9720" ,"0","1","1","1"},
            {"k435+780-2","14098","9750" ,"0","1","1","1"},
            {"k435+780-3","14098","9780" ,"0","1","1","1"},
            {"k435+780-4","14151","9720","0","0","1","1"},
            {"k435+780-5","14151","9750","0","0","1","1"},
            {"k435+780-6","14151","9780","0","0","1","1"},

            {"k435+780-情报板","14122","9720" ,"0","1","3","1"},

            {"k438+593-1","14285","9850","1","0","1","1"},
            {"k438+593-2","14285","9880","1","0","1","1"},
            {"k438+593-3","14285","9910","1","0","1","1"},
            {"k438+593-4","14334","9850","1","1","1","1"},
            {"k438+593-5","14334","9880","1","1","1","1"},
            {"k438+593-6","14334","9910","1","1","1","1"},

            {"k438+593-情报板","14309","9850","1","0","3","1"},

            {"k438+852-1","14345","9720","0","1","0","1"},
            {"k438+852-2","14345","9750","0","1","0","1"},
            {"k438+852-3","14345","9780","0","1","0","1"},
            {"k438+852-4","14395","9720","0","0","0","1"},
            {"k438+852-5","14395","9750","0","0","0","1"},
            {"k438+852-6","14395","9780","0","0","0","1"},

            {"k438+902-1","14531","9850","1","0","0","1"},
            {"k438+902-2","14531","9880","1","0","0","1"},
            {"k438+902-3","14531","9910","1","0","0","1"},
            {"k438+902-4","14578","9850","1","1","0","1"},
            {"k438+902-5","14578","9880","1","1","0","1"},
            {"k438+902-6","14578","9910","1","1","0","1"},

            {"k439+182-1","14592","9720","0","1","1","1"},
            {"k439+182-2","14592","9750","0","1","1","1"},
            {"k439+182-3","14592","9780","0","1","1","1"},
            {"k439+182-4","14644","9720","0","0","1","1"},
            {"k439+182-5","14644","9750","0","0","1","1"},
            {"k439+182-6","14644","9780","0","0","1","1"},

            {"k439+182-情报板","14617","9720","0","1","3","1"},

            {"k443+506-1","15259","9850","1","0","1","1"},
            {"k443+506-2","15259","9880","1","0","1","1"},
            {"k443+506-3","15259","9910","1","0","1","1"},
            {"k443+506-4","15308","9850","1","1","1","1"},
            {"k443+506-5","15308","9880","1","1","1","1"},
            {"k443+506-6","15308","9910","1","1","1","1"},

            {"k443+506-情报板","15284","9850","1","0","3","1"},

            {"k443+801-1","15328","9720","0","1","0","1"},
            {"k443+801-2","15328","9750","0","1","0","1"},
            {"k443+801-3","15328","9780","0","1","0","1"},
            {"k443+801-4","15378","9720","0","0","0","1"},
            {"k443+801-5","15378","9750","0","0","0","1"},
            {"k443+801-6","15378","9780","0","0","0","1"},

            {"k443+853-1","15529","9850","1","0","0","1"},
            {"k443+853-2","15529","9880","1","0","0","1"},
            {"k443+853-3","15529","9910","1","0","0","1"},
            {"k443+853-4","15579","9850","1","1","0","1"},
            {"k443+853-5","15579","9880","1","1","0","1"},
            {"k443+853-6","15579","9910","1","1","0","1"},

            {"k444+146-1","15607","9720","0","1","1","1"},
            {"k444+146-2","15607","9750","0","1","1","1"},
            {"k444+146-3","15607","9780","0","1","1","1"},
            {"k444+146-4","15657","9720","0","0","1","1"},
            {"k444+146-5","15657","9750","0","0","1","1"},
            {"k444+146-6","15657","9780","0","0","1","1"},

            {"k444+146-情报板","15632","9720","0","1","3","1"},

            {"k448+126-1","16050","9850","1","0","1","1"},
            {"k448+126-2","16050","9880","1","0","1","1"},
            {"k448+126-3","16050","9910","1","0","1","1"},
            {"k448+126-4","16103","9850","1","1","1","1"},
            {"k448+126-5","16103","9880","1","1","1","1"},
            {"k448+126-6","16103","9910","1","1","1","1"},

            {"k448+126-情报板","16075","9850","1","0","3","1"},

            {"k448+421-1","16138","9720","0","1","0","1"},
            {"k448+421-2","16138","9750","0","1","0","1"},
            {"k448+421-3","16138","9780","0","1","0","1"},
            {"k448+421-4","16187","9720","0","0","0","1"},
            {"k448+421-5","16187","9750","0","0","0","1"},
            {"k448+421-6","16187","9780","0","0","0","1"},

            {"k448+473-1","16362","9850","1","0","0","1"},
            {"k448+473-2","16362","9880","1","0","0","1"},
            {"k448+473-3","16362","9910","1","0","0","1"},
            {"k448+473-4","16415","9850","1","1","0","1"},
            {"k448+473-5","16415","9880","1","1","0","1"},
            {"k448+473-6","16415","9910","1","1","0","1"},

            {"k448+766-1","16450","9720","0","1","1","1"},
            {"k448+766-2","16450","9750","0","1","1","1"},
            {"k448+766-3","16450","9780","0","1","1","1"},
            {"k448+766-4","16503","9720","0","0","1","1"},
            {"k448+766-5","16503","9750","0","0","1","1"},
            {"k448+766-6","16503","9780","0","0","1","1"},

            {"k448+766-情报板","16475","9720","0","1","3","1"},

            {"k451+418-1","17063","9850","1","0","1","1"},
            {"k451+418-2","17063","9880","1","0","1","1"},
            {"k451+418-3","17063","9910","1","0","1","1"},
            {"k451+418-4","17121","9850","1","1","1","1"},
            {"k451+418-5","17121","9880","1","1","1","1"},
            {"k451+418-6","17121","9910","1","1","1","1"},

            {"k451+418-情报板","17088","9850","1","0","3","1"},

            {"k451+698-1","17146","9720","0","1","0","1"},
            {"k451+698-2","17146","9750","0","1","0","1"},
            {"k451+698-3","17146","9780","0","1","0","1"},
            {"k451+698-4","17199","9720","0","0","0","1"},
            {"k451+698-5","17199","9750","0","0","0","1"},
            {"k451+698-6","17199","9780","0","0","0","1"},

            {"k451+763-1","17357","9850","1","0","0","1"},
            {"k451+763-2","17357","9880","1","0","0","1"},
            {"k451+763-3","17357","9910","1","0","0","1"},
            {"k451+763-4","17410","9850","1","1","0","1"},
            {"k451+763-5","17410","9880","1","1","0","1"},
            {"k451+763-6","17410","9910","1","1","0","1"},

            {"k452+046-1","17452","9720","0","1","1","1"},
            {"k452+046-2","17452","9750","0","1","1","1"},
            {"k452+046-3","17452","9780","0","1","1","1"},
            {"k452+046-4","17500","9720","0","0","1","1"},
            {"k452+046-5","17500","9750","0","0","1","1"},
            {"k452+046-6","17500","9780","0","0","1","1"},

            {"k452+046-情报板","17479","9720","0","1","3","1"},

            {"k454+775.5-1","17858","9850","1","0","1","1"},
            {"k454+775.5-2","17858","9880","1","0","1","1"},
            {"k454+775.5-3","17858","9910","1","0","1","1"},
            {"k454+775.5-4","17909","9850","1","1","1","1"},
            {"k454+775.5-5","17909","9880","1","1","1","1"},
            {"k454+775.5-6","17909","9910","1","1","1","1"},

            {"k454+775.5-情报板","17883","9850","1","0","3","1"},

            {"k454+893.5-1","17925","9720","0","1","1","1"},
            {"k454+893.5-2","17925","9750","0","1","1","1"},
            {"k454+893.5-3","17925","9780","0","1","1","1"},
            {"k454+893.5-4","17976","9720","0","0","1","1"},
            {"k454+893.5-5","17976","9750","0","0","1","1"},
            {"k454+893.5-6","17976","9780","0","0","1","1"},

            {"k454+893.5-情报板","17950","9720","0","1","3","1"},

            {"k455+106(西岛 香港—珠澳 右变道)-1","18784","9682","0","1","4","1","6,3"},
            {"k455+106(西岛 香港—珠澳 右变道)-2","18814","9682","0","0","4","1","6"},

            {"k455+106(珠澳)-1","18784","9712","0","1","0","2"},
            {"k455+106(珠澳)-2","18784","9746","0","1","0","2"},
            {"k455+106(珠澳)-3","18784","9781","0","1","0","2"},
            {"k455+106(珠澳)-4","18814","9712","0","0","0","2"},
            {"k455+106(珠澳)-5","18814","9746","0","0","0","2"},
            {"k455+106(珠澳)-6","18814","9781","0","0","0","2"},

            {"k455+106(香港)-1","18784","9844","1","0","0","2"},
            {"k455+106(香港)-2","18784","9874","1","0","0","2"},
            {"k455+106(香港)-3","18784","9909","1","0","0","2"},
            {"k455+106(香港)-4","18814","9844","1","1","0","2"},
            {"k455+106(香港)-5","18814","9874","1","1","0","2"},
            {"k455+106(香港)-6","18814","9909","1","1","0","2"},

            {"k455+106(西岛 珠澳—香港 左变道)-1","18784","9939","1","0","4","1","7"},
            {"k455+106(西岛 珠澳—香港 左变道)-2","18814","9939","1","1","4","1","7,3"},

            {"珠澳-香港方向隧道入口红绿灯","18314","9938","1","0","2","1"},

            ///////隧道开始////////

            {"k455+468(珠澳)-1","19169","9720","0","1","0","2"},
            {"k455+468(珠澳)-2","19169","9750","0","1","0","2"},
            {"k455+468(珠澳)-3","19169","9780","0","1","0","2"},
            {"k455+468(珠澳)-4","19201","9720","0","0","0","2"},
            {"k455+468(珠澳)-5","19201","9750","0","0","0","2"},
            {"k455+468(珠澳)-6","19201","9780","0","0","0","2"},

            {"k455+468(香港)-1","19169","9850","1","0","0","2"},
            {"k455+468(香港)-2","19169","9880","1","0","0","2"},
            {"k455+468(香港)-3","19169","9910","1","0","0","2"},
            {"k455+468(香港)-4","19201","9850","1","1","0","2"},
            {"k455+468(香港)-5","19201","9880","1","1","0","2"},
            {"k455+468(香港)-6","19201","9910","1","1","0","2"},

            {"k455+873(珠澳)-1","19437","9720","0","1","1","2"},
            {"k455+873(珠澳)-2","19437","9750","0","1","1","2"},
            {"k455+873(珠澳)-3","19437","9780","0","1","1","2"},

            {"k455+873-情报板(珠澳方向)","19462","9720","0","1","3","2"},

            {"k455+873(香港)-4","19493","9850","1","1","1","2"},
            {"k455+873(香港)-5","19493","9880","1","1","1","2"},
            {"k455+873(香港)-6","19493","9910","1","1","1","2"},

            {"k455+873-情报板(香港方向)","19462","9850","1","0","3","2"},

            {"k456+278(珠澳)-1","19647","9720","0","1","0","2"},
            {"k456+278(珠澳)-2","19647","9750","0","1","0","2"},
            {"k456+278(珠澳)-3","19647","9780","0","1","0","2"},
            {"k456+278(珠澳)-4","19678","9720","0","0","0","2"},
            {"k456+278(珠澳)-5","19678","9750","0","0","0","2"},
            {"k456+278(珠澳)-6","19678","9780","0","0","0","2"},

            {"k456+278(香港)-1","19647","9850","1","0","0","2"},
            {"k456+278(香港)-2","19647","9880","1","0","0","2"},
            {"k456+278(香港)-3","19647","9910","1","0","0","2"},
            {"k456+278(香港)-4","19678","9850","1","1","0","2"},
            {"k456+278(香港)-5","19678","9880","1","1","0","2"},
            {"k456+278(香港)-6","19678","9910","1","1","0","2"},

            {"k456+683(珠澳)-1","19838","9720","0","1","0","2"},
            {"k456+683(珠澳)-2","19838","9750","0","1","0","2"},
            {"k456+683(珠澳)-3","19838","9780","0","1","0","2"},
            {"k456+683(珠澳)-4","19867","9720","0","0","0","2"},
            {"k456+683(珠澳)-5","19867","9750","0","0","0","2"},
            {"k456+683(珠澳)-6","19867","9780","0","0","0","2"},

            {"k456+683(香港)-1","19838","9850","1","0","0","2"},
            {"k456+683(香港)-2","19838","9880","1","0","0","2"},
            {"k456+683(香港)-3","19838","9910","1","0","0","2"},
            {"k456+683(香港)-4","19867","9850","1","1","0","2"},
            {"k456+683(香港)-5","19867","9880","1","1","0","2"},
            {"k456+683(香港)-6","19867","9910","1","1","0","2"},

            {"k457+088(珠澳)-1","20102","9720","0","1","1","2"},
            {"k457+088(珠澳)-2","20102","9750","0","1","1","2"},
            {"k457+088(珠澳)-3","20102","9780","0","1","1","2"},

            {"k457+088-情报板(珠澳方向)","20127","9720","0","1","3","2"},

            {"k457+088(香港)-4","20157","9850","1","1","1","2"},
            {"k457+088(香港)-5","20157","9880","1","1","1","2"},
            {"k457+088(香港)-6","20157","9910","1","1","1","2"},

            {"k457+088-情报板(香港方向)","20127","9850","1","0","3","2"},

            {"k457+583(珠澳)-1","20300","9720","0","1","0","2"},
            {"k457+583(珠澳)-2","20300","9750","0","1","0","2"},
            {"k457+583(珠澳)-3","20300","9780","0","1","0","2"},
            {"k457+583(珠澳)-4","20335","9720","0","0","0","2"},
            {"k457+583(珠澳)-5","20335","9750","0","0","0","2"},
            {"k457+583(珠澳)-6","20335","9780","0","0","0","2"},

            {"k457+583(香港)-1","20300","9850","1","0","0","2"},
            {"k457+583(香港)-2","20300","9880","1","0","0","2"},
            {"k457+583(香港)-3","20300","9910","1","0","0","2"},
            {"k457+583(香港)-4","20335","9850","1","1","0","2"},
            {"k457+583(香港)-5","20335","9880","1","1","0","2"},
            {"k457+583(香港)-6","20335","9910","1","1","0","2"},

            {"k457+966(珠澳)-1","20497","9720","0","1","0","2"},
            {"k457+966(珠澳)-2","20497","9750","0","1","0","2"},
            {"k457+966(珠澳)-3","20497","9780","0","1","0","2"},
            {"k457+966(珠澳)-4","20530","9720","0","0","0","2"},
            {"k457+966(珠澳)-5","20530","9750","0","0","0","2"},
            {"k457+966(珠澳)-6","20530","9780","0","0","0","2"},

            {"k457+966(香港)-1","20497","9850","1","0","0","2"},
            {"k457+966(香港)-2","20497","9880","1","0","0","2"},
            {"k457+966(香港)-3","20497","9910","1","0","0","2"},
            {"k457+966(香港)-4","20530","9850","1","1","0","2"},
            {"k457+966(香港)-5","20530","9880","1","1","0","2"},
            {"k457+966(香港)-6","20530","9910","1","1","0","2"},

            {"k458+393(珠澳)-1","20768","9720","0","1","1","2"},
            {"k458+393(珠澳)-2","20768","9750","0","1","1","2"},
            {"k458+393(珠澳)-3","20768","9780","0","1","1","2"},

            {"k458+393-情报板(珠澳方向)","20795","9720","0","1","3","2"},

            {"k458+393(香港)-4","20822","9850","1","1","1","2"},
            {"k458+393(香港)-5","20822","9880","1","1","1","2"},
            {"k458+393(香港)-6","20822","9910","1","1","1","2"},

            {"k458+393-情报板(香港方向)","20793","9850","1","0","3","2"},


            {"k458+821(珠澳)-1","20970","9720","0","1","0","2"},
            {"k458+821(珠澳)-2","20970","9750","0","1","0","2"},
            {"k458+821(珠澳)-3","20970","9780","0","1","0","2"},
            {"k458+821(珠澳)-4","21003","9720","0","0","0","2"},
            {"k458+821(珠澳)-5","21003","9750","0","0","0","2"},
            {"k458+821(珠澳)-6","21003","9780","0","0","0","2"},

            {"k458+821(香港)-1","20970","9850","1","0","0","2"},
            {"k458+821(香港)-2","20970","9880","1","0","0","2"},
            {"k458+821(香港)-3","20970","9910","1","0","0","2"},
            {"k458+821(香港)-4","21003","9850","1","1","0","2"},
            {"k458+821(香港)-5","21003","9880","1","1","0","2"},
            {"k458+821(香港)-6","21003","9910","1","1","0","2"},



            {"k459+266(珠澳)-1","21159","9720","0","1","0","2"},
            {"k459+266(珠澳)-2","21159","9750","0","1","0","2"},
            {"k459+266(珠澳)-3","21159","9780","0","1","0","2"},
            {"k459+266(珠澳)-4","21192","9720","0","0","0","2"},
            {"k459+266(珠澳)-5","21192","9750","0","0","0","2"},
            {"k459+266(珠澳)-6","21192","9780","0","0","0","2"},

            {"k459+266(香港)-1","21159","9850","1","0","0","2"},
            {"k459+266(香港)-2","21159","9880","1","0","0","2"},
            {"k459+266(香港)-3","21159","9910","1","0","0","2"},
            {"k459+266(香港)-4","21192","9850","1","1","0","2"},
            {"k459+266(香港)-5","21192","9880","1","1","0","2"},
            {"k459+266(香港)-6","21192","9910","1","1","0","2"},



            {"k459+631(珠澳)-1","21430","9720","0","1","1","2"},
            {"k459+631(珠澳)-2","21430","9750","0","1","1","2"},
            {"k459+631(珠澳)-3","21430","9780","0","1","1","2"},

            {"k459+631-情报板(珠澳方向)","21459","9720","0","1","3","2"},

            {"k459+631(香港)-4","21484","9850","1","1","1","2"},
            {"k459+631(香港)-5","21484","9880","1","1","1","2"},
            {"k459+631(香港)-6","21484","9910","1","1","1","2"},

            {"k459+631-情报板(香港方向)","21459","9850","1","0","3","2"},


            {"k460+058(珠澳)-1","21638","9720","0","1","0","2"},
            {"k460+058(珠澳)-2","21638","9750","0","1","0","2"},
            {"k460+058(珠澳)-3","21638","9780","0","1","0","2"},
            {"k460+058(珠澳)-4","21672","9720","0","0","0","2"},
            {"k460+058(珠澳)-5","21672","9750","0","0","0","2"},
            {"k460+058(珠澳)-6","21672","9780","0","0","0","2"},

            {"k460+058(香港)-1","21638","9850","1","0","0","2"},
            {"k460+058(香港)-2","21638","9880","1","0","0","2"},
            {"k460+058(香港)-3","21638","9910","1","0","0","2"},
            {"k460+058(香港)-4","21672","9850","1","1","0","2"},
            {"k460+058(香港)-5","21672","9880","1","1","0","2"},
            {"k460+058(香港)-6","21672","9910","1","1","0","2"},


            {"k460+463(珠澳)-1","21917","9720","0","1","0","2"},
            {"k460+463(珠澳)-2","21917","9750","0","1","0","2"},
            {"k460+463(珠澳)-3","21917","9780","0","1","0","2"},
            {"k460+463(珠澳)-4","21948","9720","0","0","0","2"},
            {"k460+463(珠澳)-5","21948","9750","0","0","0","2"},
            {"k460+463(珠澳)-6","21948","9780","0","0","0","2"},

            {"k460+463(香港)-1","21917","9850","1","0","0","2"},
            {"k460+463(香港)-2","21917","9880","1","0","0","2"},
            {"k460+463(香港)-3","21917","9910","1","0","0","2"},
            {"k460+463(香港)-4","21948","9850","1","1","0","2"},
            {"k460+463(香港)-5","21948","9880","1","1","0","2"},
            {"k460+463(香港)-6","21948","9910","1","1","0","2"},

            {"k460+952(珠澳)-1","22170","9720","0","1","1","2"},
            {"k460+952(珠澳)-2","22170","9750","0","1","1","2"},
            {"k460+952(珠澳)-3","22170","9780","0","1","1","2"},

            {"k460+952-情报板(珠澳方向)","22194","9720","0","1","3","2"},


            {"k460+952(香港)-4","22221","9850","1","1","1","2"},
            {"k460+952(香港)-5","22221","9880","1","1","1","2"},
            {"k460+952(香港)-6","22221","9910","1","1","1","2"},

            {"k460+952-情报板(香港方向)","22194","9850","1","0","3","2"},

            /////隧道结束 ///


            {"k461+420(东岛 香港—珠澳 左变道)-1","22480","9676","0","1","4","1","5,3"},
            {"k461+420(东岛 香港—珠澳 左变道)-2","22511","9676","0","0","4","1","5"},

            {"k461+420(珠澳)-1","22480","9711","0","1","0","2"},
            {"k461+420(珠澳)-2","22480","9743","0","1","0","2"},
            {"k461+420(珠澳)-3","22480","9777","0","1","0","2"},
            {"k461+420(珠澳)-4","22511","9711","0","0","0","2"},
            {"k461+420(珠澳)-5","22511","9743","0","0","0","2"},
            {"k461+420(珠澳)-6","22511","9777","0","0","0","2"},

            {"k461+420(香港)-1","22480","9846","1","0","0","2"},
            {"k461+420(香港)-2","22480","9877","1","0","0","2"},
            {"k461+420(香港)-3","22480","9907","1","0","0","2"},
            {"k461+420(香港)-4","22511","9846","1","1","0","2"},
            {"k461+420(香港)-5","22511","9877","1","1","0","2"},
            {"k461+420(香港)-6","22511","9907","1","1","0","2"},

            {"k461+420(东岛 珠澳—香港 右变道)-1","22480","9940","1","0","4","1","8"},
            {"k461+420(东岛 珠澳—香港 右变道)-2","22511","9940","1","1","4","1","8,3"},

            {"k461+852-1","23400","9850","1","0","1","1"},
            {"k461+852-2","23400","9880","1","0","1","1"},
            {"k461+852-3","23400","9910","1","0","1","1"},
            {"k461+852-4","23454","9850","1","1","1","1"},
            {"k461+852-5","23454","9880","1","1","1","1"},
            {"k461+852-6","23454","9910","1","1","1","1"},

            {"k461+852-情报板","23425","9850","1","0","3","1"},

            {"k461+875-1","23595","9716","0","1","1","1"},
            {"k461+875-2","23595","9746","0","1","1","1"},
            {"k461+875-3","23595","9776","0","1","1","1"},
            {"k461+875-4","23642","9716","0","0","1","1"},
            {"k461+875-5","23642","9746","0","0","1","1"},
            {"k461+875-6","23642","9776","0","0","1","1"},

            {"k461+875-情报板","23620","9716","0","1","3","1"},

            {"k432-情报板","9840","10125","1","1","3","1"},

            {"香港-珠澳方向隧道入口红绿灯","23199","9617","0","0","2","1"}


    };
    public static void createTable(DbUtils db){
        try {
            boolean isExist = db.tableIsExist(FileDir.class);
            db.createTableIfNotExist(FileDir.class);
            boolean isExistAttr = db.tableIsExist(Attr.class);
            db.createTableIfNotExist(Attr.class);
            if(!isExist) {
                List<FileDir> fileDirs = new ArrayList<>();
                FileDir fileDir = new FileDir();
                fileDir.setId(1);
                fileDir.setParent_id(0);
                fileDir.setName("民用车");
                fileDir.setType(0);
                fileDirs.add(fileDir);
                fileDir = new FileDir();
                fileDir.setId(2);
                fileDir.setParent_id(0);
                fileDir.setName("汽车");
                fileDir.setType(0);
                fileDirs.add(fileDir);

                fileDir = new FileDir();
                fileDir.setId(3);
                fileDir.setParent_id(0);
                fileDir.setName("交安设备");
                fileDir.setType(0);
                fileDirs.add(fileDir);

                for (int i = 1; i <= 14; i++) {
                    fileDir = new FileDir();
                    fileDir.setId((i + 3));
                    fileDir.setType(1);
                    fileDir.setName("民用车" + i);
                    fileDir.setParent_id(1);
                    fileDir.setDir("file:///android_asset/mingyong/" + i + ".png");
                    fileDirs.add(fileDir);
                }
                for (int i = 1; i <= 26; i++) {
                    fileDir = new FileDir();
                    fileDir.setId((i + 17));
                    fileDir.setType(1);
                    fileDir.setName("汽车" + i);
                    fileDir.setParent_id(2);
                    fileDir.setDir("file:///android_asset/qiche/" + i + ".png");
                    fileDirs.add(fileDir);
                }
                String[] shebei = new String[]{
                        "警示灯路栏",
                        "隔离墩/水马",
                        "闪光箭头",
                        "警示频闪灯",
                        "车辆闪光灯",
                        "临时交通控制信号设施",
                        "移动式标致车",
                        "限速标志",
                        "解除限速标志",
                        "限速标志",
                        "解除限速标志",
                        "禁止超车标志",
                        "解除禁止超车标志",
                        "解除限速标志",
                        "施工距离标志",
                        "施工距离标志",
                        "施工长度标志",
                        "慢行标志",
                        "导向标志",
                        "导向标志",
                        "交通锥",
                        "交通锥",
                        "车道数减少标志",
                        "车道数减少标志",
                        "车道数减少标志",
                        "车道数减少标志",
                        "导向标志",
                        "出口标志",
                        "重车靠右停靠区",
                        "限速标志",
                        "警示灯"
                };
                for (int i = 1; i <= 31; i++) {
                    fileDir = new FileDir();
                    fileDir.setId((i + 43));
                    fileDir.setType(1);
                    fileDir.setName(shebei[i - 1]);
                    fileDir.setParent_id(3);
                    fileDir.setDir("file:///android_asset/shebei/" + i + ".png");
                    fileDirs.add(fileDir);
                }
                for (int i = 0; i < fileDirs.size(); i++) {
                    db.save(fileDirs.get(i));
                }
            }

            if(!isExistAttr){
                restoreAttr(0);
            }
        }catch (Exception e){
            //Log.e("db_createTable",e.getMessage());
        }
    }

    /**
     * 还原attr
     * @param db
     */
    public static void restoreAttr(int bgId){
        Attr attr = null;
        for(int i = 0 ; i < data.length;i++){
            int default_value = 0 ;
            attr = new Attr();
            attr.setTitle(data[i][0]);

            if(data[i][3].equals("0")){
                attr.setPointX(Double.parseDouble(data[i][1])+22);
                attr.setPointY(Double.parseDouble(data[i][2])+24);
                if(data[i][4].equals("0")){
                    attr.setState(1);
                }else{
                    attr.setState(3);
                }
            }else {
                attr.setPointX(Double.parseDouble(data[i][1])+22);
                attr.setPointY(Double.parseDouble(data[i][2])+24);
                if(data[i][4].equals("0")){
                    attr.setState(2);
                }else{
                    attr.setState(3);
                }
            }
            attr.setFilp(Integer.parseInt(data[i][3]));//0左或1右
            attr.setRotation(Integer.parseInt(data[i][4]));//0前或1后

            String[] sp = attr.getTitle().split("-");
            if(sp.length>=2){
                if(data[i][3].equals("0")){
                    if(!sp[1].contains("情报板")) {
                        if (sp[1].equals("1") || sp[1].equals("4")) {
                            attr.setPath("80");
                        } else {
                            attr.setPath("100");
                        }
                    }
                }else{
                    if(!sp[1].contains("情报板")) {
                        if (sp[1].equals("3") || sp[1].equals("6")) {
                            attr.setPath("80");
                        } else {
                            attr.setPath("100");
                        }
                    }
                }
                if(sp[0].equals("k454+775.5")||sp[0].equals("k461+875")){
                    if(data[i][3].equals("0")){
                        if(sp[1].equals("2")||sp[1].equals("3")||sp[1].equals("5")||sp[1].equals("6")){
                            attr.setPath("90");
                        }
                    }else{
                        if(sp[1].equals("1")||sp[1].equals("2")||sp[1].equals("4")||sp[1].equals("5")){
                            attr.setPath("90");
                        }
                    }

                }
            }




            if(data[i].length<5){
                attr.setType(0);
            }else{
                int type = Integer.parseInt(data[i][5]);
                int position = Integer.parseInt(data[i][6]);

                attr.setType(type);
                attr.setPosition(position);
                if(type==1&&position==1){
                    if(data[i][4].equals("0")){
                        attr.setState(4);
                    }
                }else if(type==3){
                    attr.setState(2);
                    attr.setPointX(Double.parseDouble(data[i][1])+24);
                    attr.setPointY(Double.parseDouble(data[i][2])+20);
                    if(position==1){
                        attr.setPath("桥面行车，注意横风");
                    }else if(position==2){
                        attr.setPath("隧道行车，禁止变道");
                    }
                }else if(type==2){
                    attr.setState(11);
                }else if(type==4){
                    if(data[i][7].contains(",")){
                        String[] s = data[i][7].split(",");
                        default_value = Integer.parseInt(s[0]);
                        int state = Integer.parseInt(s[1]);
                        attr.setState(state);
                    }else{
                        int state = Integer.parseInt(data[i][7]);
                        default_value = state;
                        attr.setState(state);
                    }

                }

                /**
                 * 将情报板中的交通灯移到 之前的交通灯控制板
                 */
                if(type==1){
                    if(data[i][3].equals("0")&&data[i][4].equals("1")||data[i][3].equals("1")&&data[i][4].equals("1")){
                        attr.setType(0);
                    }
                }


            }
            attr.setBgId(bgId);
            attr.setDefault_value(default_value);


            try {
                db.save(attr);
            }catch (Exception e){

            }
        }
    }
    /**
     * 查询单条数据
     * @param db
     * @param id
     * @return
     */
    public static FileDir find(DbUtils db,int id){
        FileDir fileDir = null ;
        try {
            fileDir = db.findById(FileDir.class,id);
        }catch (Exception e){
            //Log.e("db_find",e.getMessage());
        }
        return fileDir;
    }
    /**
     * 保存数据
     * @param db
     * @param fileDir
     */
    public static void save(DbUtils db, FileDir fileDir){
        try {
            db.saveOrUpdate(fileDir);
        }catch (Exception e){
            Log.e("db_save",e.getMessage());
        }
    }

    /**
     * 保存坐标
     * @param db
     * @param fileDir
     */
    public static void save(DbUtils db, Attr fileDir){
        try {
            if(fileDir.getId()>0){
                db.update(fileDir);
            }else{
                fileDir.setId(0);
                db.save(fileDir);
            }
        }catch (Exception e){
            Log.e("db_save",e.getMessage());
        }
    }

    /**
     * 删除数据
     * @param db
     * @param fileDir
     */
    public static void delete(DbUtils db,Attr fileDir){
        try{
            db.delete(fileDir);
        }catch (Exception e){
            Log.e("db_delete",e.getMessage());
        }
    }

    /**
     * 清除当前配置
     * @param db
     * @param bg_id
     */
    public static void delete_all(DbUtils db,int bg_id){
        try{
            db.delete(Attr.class, WhereBuilder.b("bgId","=",bg_id).and("state","=","0"));
        }catch (Exception e){
            Log.e("db_delete_all",e.getMessage());
        }
    }


    /**
     * 删除数据
     * @param db
     * @param fileDir
     */
    public static void delete(DbUtils db,FileDir fileDir){
        try{
            int parent_id = fileDir.getId();
            db.delete(fileDir);
            db.delete(Selector.from(FileDir.class).where("parent_id","=",parent_id));
        }catch (Exception e){
            Log.e("db_delete",e.getMessage());
        }
    }

    /**
     * 查询当前目录
     * @param db
     * @return
     */
    public static List<Attr> findAttrList(DbUtils db,int bg_id){
        List<Attr> fileDirs = null;
        try{
            fileDirs = db.findAll(Selector.from(Attr.class).where("bgId","=",bg_id));
            //fileDirs = db.findAll(Selector.from(Attr.class).where("bgId","=",bg_id).or("state",">","0"));
        }catch (Exception e){
            Log.e("db_findList",e.getMessage());
        }
        return  fileDirs;
    }

    /**
     * 查询当前目录
     * @param db
     * @param parent_id
     * @return
     */
    public static List<FileDir> findList(DbUtils db, int parent_id){
        List<FileDir> fileDirs = null;
        try{
             fileDirs = db.findAll(Selector.from(FileDir.class).where("parent_id","=",parent_id).orderBy("type"));
        }catch (Exception e){
            Log.e("db_findList",e.getMessage());
        }
        return  fileDirs;
    }

    /**
     * 复制单个文件
     * @return boolean
     */
    public static String copyFile(Context context,String oldPath) {
        Date date = new Date();
        String newPath = null;
        try {
            int bytesum = 0;
            int byteread = 0;
            File oldfile = new File(oldPath);
            if (oldfile.exists()) {
                String fileName=oldfile.getName();
                String prefix=fileName.substring(fileName.lastIndexOf(".")+1);
                newPath = context.getFilesDir()+"/"+date.getTime()+"."+prefix;
                InputStream inStream = new FileInputStream(oldPath); //读入原文件
                FileOutputStream fs = new FileOutputStream(newPath);
                byte[] buffer = new byte[1444];
                while ( (byteread = inStream.read(buffer)) != -1) {
                    bytesum += byteread; //字节数 文件大小
                    System.out.println(bytesum);
                    fs.write(buffer, 0, byteread);
                }
                inStream.close();
            }
        }
        catch (Exception e) {
            System.out.println("复制单个文件操作出错");
            e.printStackTrace();
        }
        return newPath;
    }


    /**
     * 关机
     * @param activity
     */
    public static void shutdown(Activity activity){
        try {

            //获得ServiceManager类
            Class<?> ServiceManager = Class
                    .forName("android.os.ServiceManager");

            //获得ServiceManager的getService方法
            Method getService = ServiceManager.getMethod("getService", java.lang.String.class);

            //调用getService获取RemoteService
            Object oRemoteService = getService.invoke(null,Context.POWER_SERVICE);

            //获得IPowerManager.Stub类
            Class<?> cStub = Class
                    .forName("android.os.IPowerManager$Stub");
            //获得asInterface方法
            Method asInterface = cStub.getMethod("asInterface", android.os.IBinder.class);
            //调用asInterface方法获取IPowerManager对象
            Object oIPowerManager = asInterface.invoke(null, oRemoteService);
            //获得shutdown()方法
            Method shutdown = oIPowerManager.getClass().getMethod("shutdown",boolean.class,boolean.class);
            //调用shutdown()方法
            shutdown.invoke(oIPowerManager,false,true);

        } catch (Exception e) {
            activity.finish();
        }
    }


    /**
     * 获取屏幕中的控件值
     * @param mapView
     * @return
     */
    public static List<Attr> getSticker(TileView mapView){
        List<Attr> attrs = new ArrayList<>();
        MarkerPlugin markerPlugin = mapView.getPlugin(MarkerPlugin.class);
        int count = markerPlugin.getChildCount();
        for(int i=0;i<count;i++){
            if(markerPlugin.getChildAt(i) instanceof StickerImageView){
                StickerImageView stickerImageView = (StickerImageView)markerPlugin.getChildAt(i);
                String path = stickerImageView.getPath().getPath();
                Attr att = new Attr();
                double[] coordinate = (double[])stickerImageView.getTag();

                att.setPointX(coordinate[0]);
                att.setPointY(coordinate[1]);
                att.setRotation(stickerImageView.getRotation());
                att.setScale(stickerImageView.getScale());
                int fp = stickerImageView.getmFilp();
                if(fp==1){
                    fp = 0 ;
                }else{
                    fp = 1 ;
                }
                int islock = 1 ;
                if(stickerImageView.isLock){
                    islock = 0 ;
                }
                att.setIs_lock(islock);
                att.setFilp(fp);
                att.setState(0);
                att.setPath(path);
                attrs.add(att);
            }
        }


        return attrs;
    }

}
